package gsw.tool.pluggable.compat;

import android.os.Build;
import android.os.UserHandle;

import gsw.tool.pluggable.utils.reflect.MethodUtils;

/**
 * 用户信息获取类
 */
public class CompatUserHandler {

    /**
     * 用来获取UserId
     *
     * @return
     */
    public static int getCallingUserId() {
        try {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                return (int) MethodUtils.invokeStaticMethod(UserHandle.class, "getCallingUserId");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return 0;
    }
}
